import { getToken } from './auth'
import axios from 'axios'

// 下载文件
export function download ({ url, method, params }) {
  return new Promise((resolve, reject) => {
    axios({
      method,
      url,
      responseType: 'blob',
      headers: {
        token: getToken()
      },
      params
    }).then((res) => {
      resolve(res)
    }).catch(() => {
      const err = { dec: 'error' }
      reject(err)
    })
  })
}
